class PcatesController < ApplicationController
  before_filter :login_required
  before_filter :check_editor_right
  # GET /pcates
  # GET /pcates.xml
  def index
    @pcates = Pcate.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @pcates }
    end
  end

  # GET /pcates/1
  # GET /pcates/1.xml
  def show
    @pcate = Pcate.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @pcate }
    end
  end

  # GET /pcates/new
  # GET /pcates/new.xml
  def new
    @pcate = Pcate.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @pcate }
    end
  end

  # GET /pcates/1/edit
  def edit
    @pcate = Pcate.find(params[:id])
  end

  # POST /pcates
  # POST /pcates.xml
  def create
    @pcate = Pcate.new(params[:pcate])

    respond_to do |format|
      if @pcate.save
        flash[:notice] = 'Pcate was successfully created.'
        format.html { redirect_to(@pcate) }
        format.xml  { render :xml => @pcate, :status => :created, :location => @pcate }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @pcate.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /pcates/1
  # PUT /pcates/1.xml
  def update
    @pcate = Pcate.find(params[:id])

    respond_to do |format|
      if @pcate.update_attributes(params[:pcate])
        flash[:notice] = 'Pcate was successfully updated.'
        format.html {  redirect_to(pcates_url) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @pcate.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /pcates/1
  # DELETE /pcates/1.xml
  def destroy
    @pcate = Pcate.find(params[:id])
    @pcate.destroy

    respond_to do |format|
      format.html { redirect_to(pcates_url) }
      format.xml  { head :ok }
    end
  end
end
